#include "ImageResource.h"

using namespace SolidityEngine;


ImageResource::ImageResource(const std::string& path ,const std::string& name):
    Resource(path,name),
    Image()
{
}

ImageResource::~ImageResource()
{
}

void ImageResource::Load()
{
    //The final optimized image
    SDL_FreeSurface(_rendersurface);

    _rendersurface=IMG_Load(path.c_str());
    if(!_rendersurface){
        throw "Error: Could not load image!";
    }


    count++;
}

void ImageResource::UnLoad()
{
    count--;
    if(count<1){
        SDL_FreeSurface(_rendersurface);
    }
}

ImageResource* ImageResource::_Clone()
{
    return new ImageResource(*this);
}

